home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games Extra 1996 June / Amiga Games Extra 1996 #6.iso / userbox / publicdomain / gnutar / source.lzh / source / sas_amiga.c < prev    next >
C/C++ Source or Header  |  1996-03-11  |  3KB  |  160 lines

  1. /*
  2.  *  Amiga specific functions
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include <sys/dir.h>
  9. #include <sys/stat.h>
  10. #include <time.h>
  11. #include <dos/dos.h>
  12. #include <proto/dos.h>
  13.  
  14.  
  15. /* maxmium pathlength for AmigaDOS */
  16.  
  17. #define MAXPATHLEN (255) /* BSTR */
  18.  
  19. /* UNIX protection bits */
  20.  
  21. #define S_IRWXU 0000700                 /* RWX mask for owner */
  22. #define S_IRUSR 0000400                 /* R for owner */
  23. #define S_IWUSR 0000200                 /* W for owner */
  24. #define S_IXUSR 0000100                 /* X for owner */
  25.  
  26. #define S_IRWXG 0000070                 /* RWX mask for group */
  27. #define S_IRGRP 0000040                 /* R for group */
  28. #define S_IWGRP 0000020                 /* W for group */
  29. #define S_IXGRP 0000010                 /* X for group */
  30.  
  31. #define S_IRWXO 0000007                 /* RWX mask for other */
  32. #define S_IROTH 0000004                 /* R for other */
  33. #define S_IWOTH 0000002                 /* W for other */
  34. #define S_IXOTH 0000001                 /* X for other */
  35.  
  36. int sas_chmod(const char *filename, int modes)
  37. {
  38.  unsigned long mask = FIBF_READ | FIBF_WRITE | FIBF_EXECUTE | FIBF_DELETE; /* clear; low-active */
  39.  
  40.     if(modes & S_IRUSR) mask &= ~FIBF_READ;
  41.     if(modes & S_IWUSR) mask &= ~FIBF_WRITE;
  42.     if(modes & S_IXUSR) mask &= ~FIBF_EXECUTE;
  43.     if(modes & S_IWUSR) mask &= ~FIBF_DELETE;
  44.  
  45.     if(modes & S_IRGRP) mask |= FIBF_GRP_READ;
  46.     if(modes & S_IWGRP) mask |= FIBF_GRP_WRITE;
  47.     if(modes & S_IXGRP) mask |= FIBF_GRP_EXECUTE;
  48.     if(modes & S_IWGRP) mask |= FIBF_GRP_DELETE;
  49.  
  50.     if(modes & S_IROTH) mask |= FIBF_OTR_READ;
  51.     if(modes & S_IWOTH) mask |= FIBF_OTR_WRITE;
  52.     if(modes & S_IXOTH) mask |= FIBF_OTR_EXECUTE;
  53.     if(modes & S_IWOTH) mask |= FIBF_OTR_DELETE;
  54.  
  55.         SetProtection((APTR) filename, mask);
  56.  
  57.         return 0; /* returning error would have to mess with errno, too */
  58. }
  59.  
  60. int sas_stat(const char *filename, struct stat *st)
  61. {
  62.         unsigned short mode;
  63.         int result;
  64.  
  65.         result = lstat(filename,st);
  66.  
  67.         mode = st->st_mode & 0xff00; /* mask out file mode bits */
  68.  
  69.         /* convert them to closest UNIX equivalents */
  70.         if (st->st_mode & S_IREAD) mode |= S_IRUSR | S_IRGRP | S_IROTH;
  71.         if (st->st_mode & S_IWRITE) mode |= S_IWUSR | S_IWGRP | S_IWOTH;
  72.         if (st->st_mode & S_IEXECUTE) mode |= S_IXUSR | S_IXGRP | S_IXOTH;
  73.  
  74.         st->st_mode = mode;
  75.  
  76.         return result;
  77. }
  78.  
  79. char *getwd(char *buf)
  80. {
  81.     return(getcwd(buf, MAXPATHLEN));
  82. }
  83.  
  84. int readlink(char *path, char *name, int max)
  85. {
  86.     return(-1);
  87. }
  88.  
  89. int symlink(void)
  90. {
  91.     return(-1);
  92. }
  93.  
  94. int utime(void)
  95. {
  96.     return(0);
  97. }
  98.  
  99. int umask(void)
  100. {
  101.     return(0);
  102. }
  103.  
  104. int fork(void)
  105. {
  106.     return(-1);
  107. }
  108.  
  109. int execlp(void)
  110. {
  111.     return(-1);
  112. }
  113.  
  114.  
  115. int findgid(void)
  116. {
  117.     return(0);
  118. }
  119.  
  120. int finduid(void)
  121. {
  122.     return(0);
  123. }
  124.  
  125. int pipe(void)
  126. {
  127.     return(-1);
  128. }
  129.  
  130. int dup(void)
  131. {
  132.     return(-1);
  133. }
  134.  
  135. int setmode(void)
  136. {
  137.     return(0);
  138. }
  139.  
  140. extern int wildmat(char *s, char *p);
  141.  
  142. int fnmatch (char *pattern, char *string, int flags)
  143. {
  144.  wildmat(string, pattern);
  145. }
  146.  
  147. #include <sys/timeb.h>
  148.  
  149. void ftime(struct timeb *ftz)
  150. {
  151.  extern time_t timezone;
  152.  
  153.  (void)time((time_t *) ftz->time);
  154.  
  155.  /* Set the timezone global. */
  156.  tzset();
  157.  
  158.  ftz->timezone = (int) timezone / 60;
  159. }
  160.